package org.snail.chat.service.chatchain.chain;


import lombok.extern.log4j.Log4j;
import org.snail.chat.service.chatchain.dao.ChatCreateOrUpdateDAO;
import org.snail.dept.bean.TreeNode;

import java.util.List;
import java.util.Map;

/**
 * 获取固定运营团队人员到群组,管理员
 */
@Log4j
public class OperatorChatCreateOrUpdateHandler extends ChatCreateOrUpdateHandler {


    @Override
    public void doCreateOrUpdate(TreeNode treeNode, Map<String, ChatCreateOrUpdateDAO> chatCreateOrUpdateDAOMap) throws Exception {

        //获取当前树的ChatCreateOrUpdateDAO
        ChatCreateOrUpdateDAO chatCreateOrUpdateDAO = getChatCreateOrUpdateDAO(treeNode, chatCreateOrUpdateDAOMap);

        List<String> userIdList = this.getHandlerRegular().getOtherUserIdList();

        if (null!=userIdList || !userIdList.isEmpty()) {

            log.info(chatCreateOrUpdateDAO.getName() + " OtherUserIdList : " + userIdList);
            //添加数据库中的人员列表到需要添加的队列中
            addUserChatCreateOrUpdateDAO(chatCreateOrUpdateDAO, userIdList);

            //重新放回到Map中
            chatCreateOrUpdateDAOMap.put(treeNode.getId(), chatCreateOrUpdateDAO);
        }

    }
}
